library(ggplot2)

dat <- read.csv("durability.csv",header=T, stringsAsFactors=FALSE)
coef <- dat[dat$Type=="coef",] 
se <- dat[dat$Type=="se",]
lb <-  coef[,3:4] - 1.96*se[,3:4]
lb$year = se$Year
ub <- coef[,3:4] + 1.96*se[,3:4]
ub$year = se$Year

titles <- c ("Racial Resentment Index","Skin-Tone Implicit Association Test"
              )

             
for (i in c(3:4)){
j <- i-2
p1 <- ggplot()
p1 <- p1 + geom_line(data=coef, aes(x=Year, y=coef[,i]))
p1 <- p1 + geom_line(data=lb, aes(x=year, y=lb[,j]), linetype =2)
p1 <- p1 + geom_line(data=ub, aes(x=year, y=ub[,j]), linetype =2)
p1 <- p1 + geom_hline(yintercept=0, linetype="dotted", size=0.5)
p1 <- p1 + scale_x_continuous(breaks=coef$Year,labels=c("2007/2008","2009","2010","2011","2012","2013")) 

p1 <- p1 + labs( x= "Year", y = "2LS2 Estimate")


#Theme
p1 <- p1+ theme(plot.background= element_rect(fill="white"),
               panel.background= element_rect(fill="white", color= "grey75"),
               panel.grid.major = element_line(color= "grey75"),
               panel.grid.minor = element_line(color= "grey80"),
               panel.grid.major.y = element_blank(),
               panel.grid.minor.y = element_blank(),
               panel.spacing.x = unit(12,"point"),
               axis.text = element_text(lineheight=0.5),
               legend.background = element_rect(fill="white"))
print(p1)
}